package com.yh.tea.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yh.tea.entity.GoodsCar;
import com.yh.tea.entity.GoodsManage;
import com.yh.tea.entity.Order;
import com.yh.tea.service.GoodsCarService;
import com.yh.tea.service.GoodsService;
import com.yh.tea.utiity.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yh
 * @since 2024-04-09
 */
@RestController
@RequestMapping("/goods-car")
public class GoodsCarController {
    @Autowired
    private GoodsCarService goodsCarService;
    @PostMapping("/add")
    public ResponseResult add(@RequestBody GoodsCar goodsCar){
        Boolean result=goodsCarService.save(goodsCar);
        return ResponseResult.success(result?"添加成功":"添加失败",result);
    }

    @PostMapping("/del")
    public ResponseResult del(@RequestBody List<Long> ids){
        Boolean result=goodsCarService.removeByIds(ids);
        return ResponseResult.success(result?"删除成功":"删除失败",result);
    }
    //修改商品信息
    @PostMapping("/update")
    public ResponseResult update(@RequestBody GoodsCar goodsCar){
        Boolean result=goodsCarService.update(goodsCar,new QueryWrapper<GoodsCar>().eq("id",goodsCar.getGoodsId()));
        return ResponseResult.success(result?"修改成功":"修改失败");
    }

//    @PostMapping("/getPage")
//    public ResponseResult getPage(@RequestBody  query){
//        return articleService.getPage(query);
//    }

}

